home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Performance Co-Pilot 1.3
/
SGI Performance Co-Pilot 1.3.iso
/
dist
/
pcp.idb
/
usr
/
pcp
/
bin
/
cron.pmlogmerge.z
/
cron.pmlogmerge
Wrap
Text File
|
1997-04-03
|
5KB
|
221 lines
#!/bin/sh
# Copyright 1995, Silicon Graphics, Inc.
# ALL RIGHTS RESERVED
#
# UNPUBLISHED -- Rights reserved under the copyright laws of the United
# States. Use of a copyright notice is precautionary only and does not
# imply publication or disclosure.
#
# U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
# Use, duplication or disclosure by the Government is subject to restrictions
# as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
# in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
# in similar or successor clauses in the FAR, or the DOD or NASA FAR
# Supplement. Contractor/manufacturer is Silicon Graphics, Inc.,
# 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
#
# THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
# INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
# DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
# PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
# GRAPHICS, INC.
#
# merge a group of logfiles, e.g. all those for today
#
# default case, w/out arguments uses the default pmlogger filename
# conventions for today's logs, namely `date +%y%m%d` for both the
# input-basename and the output-name
#
prog=`basename $0`
tmp=/tmp/$$
status=0
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
rm -f $tmp.*
force=false
_abandon()
{
echo "$prog: These error(s) are fatal, no output archive has been created."
status=1
exit
}
_warning()
{
echo "$prog: Trying to continue, although output archive may be corrupted."
force=false
}
usage="Usage: $prog [-f] [input-basename ... output-name]"
# option parsing
#
while getopts f c
do
case $c
in
f)
force=true
;;
\?) echo "$usage"
_abandon
;;
esac
done
shift `expr $OPTIND - 1`
if [ $# -eq 0 ]
then
inputlist=`date +%y%m%d`
output=$input
elif [ $# -ge 2 ]
then
inputlist=""
while [ $# -ge 2 ]
do
inputlist="$inputlist $1"
shift
done
output="$1"
else
echo "$usage"
status=1
exit
fi
fail=false
mergelist=""
for input in $inputlist
do
for file in $input.index
do
file=`basename $file .index`
empty=0
if [ ! -f "$file.index" ]
then
echo "$prog: Error: \"index\" file missing for archive \"$file\""
fail=true
elif [ ! -s "$file.index" ]
then
empty=`expr $empty + 1`
fi
if [ ! -f "$file.meta" ]
then
echo "$prog: Error: \"meta\" file missing for archive \"$file\""
fail=true
elif [ ! -s "$file.meta" ]
then
empty=`expr $empty + 1`
fi
if [ ! -f "$file.0" ]
then
echo "$prog: Error: \"volume 0\" file missing for archive \"$file\""
fail=true
elif [ ! -s "$file.0" ]
then
empty=`expr $empty + 1`
fi
if [ $empty -eq 3 ]
then
echo "$prog: Warning: archive \"$file\" is empty and will be skipped"
else
mergelist="$mergelist $file"
fi
done
done
if [ -f $output.index ]
then
echo "$prog: Error: \"index\" file already exists for output archive \"$output\""
fail=true
fi
if [ -f $output.meta ]
then
echo "$prog: Error: \"meta\" file already exists for output archive \"$output\""
fail=true
fi
if [ -f $output.0 ]
then
echo "$prog: Error: \"volume 0\" file already exists for output archive \"$output\""
fail=true
fi
$fail && _abandon
i=0
list=""
part=0
echo "Input archives to be merged:"
for input in $mergelist
do
for file in $input.index
do
if [ $i -ge 60 ]
then
echo " -> partial merge to $tmp.$part"
if /usr/pcp/bin/pmlogmerge $list $tmp.$part
then
:
else
echo "$prog: pmlogmerge failed"
_warning
fi
list=$tmp.$part
part=`expr $part + 1`
i=0
fi
file=`basename $file .index`
list="$list $file"
echo " $file\c"
numvol=`echo $file.[0-9]* | wc -w | sed -e 's/ *//g'`
if [ $numvol -gt 1 ]
then
echo " ($numvol volumes)"
else
echo
fi
i=`expr $i + 1`
done
done
if /usr/pcp/bin/pmlogmerge $list $output
then
:
else
echo "$prog: pmlogmerge failed"
_warning
fi
echo "Output archive files:"
for file in $output.meta $output.index $output.0
do
if [ -f $file ]
then
ls -l $file
else
echo "$prog: Error: file \"$file\" not created"
force=false
fi
done
if $force
then
echo "Removing input archive files ...\c"
for input in $inputlist
do
for file in $input.index
do
file=`basename $file .index`
[ "$file" = "$output" ] && continue
rm -f $file.index $file.meta $file.[0-9]*
done
done
echo " done"
fi
exit